<HTML>
<HEAD>
<TITLE>Choose Site-Terms</TITLE>
<META HTTP-EQUIV='Content-Type' CONTENT='text/html; charset=windows-1252'>
<LINK REL='stylesheet' TYPE='text/css' HREF='/widgets/bizdesk.css' ID='mainstylesheet'>
<SCRIPT LANGUAGE='VBScript'>

Option  Explicit

dim xmlSelected, sSelected

xmlSelected = null

sub initSiteTermList()
	dim objArgs, xmlSiteTermList, xmlNode

	set objArgs = window.dialogArguments

	set xmlSiteTermList = objArgs.Item("SiteTermNode")
	sSelected = objArgs.Item("Selected")
	
	if typename(xmlSiteTermList) = "IXMLDOMNode" then
		xmlSiteTermList.setAttribute "skip", "yes"
		for each xmlNode in xmlSiteTermList.childNodes
			xmlNode.setAttribute "caption", xmlNode.getAttribute("displayName")
		next
		sitetermslist.innerHTML = "<xml id='tvlist'>" & xmlSiteTermList.xml & "</xml>"
		tvSiteTermList.className = "treeView"
	end if

	' Make things look pretty.
	onWndResize()
end sub

sub onBtnOK()
	dim xmlNode
	set xmlNode = xmlSelected.cloneNode(true)
	xmlNode.removeAttribute "caption"
	window.returnValue = xmlNode
	window.close()
end sub

sub onBtnCancel()
	window.returnValue = empty
	window.close()
end sub

sub onWndResize()
	elHeader.style.width = tvSiteTermList.clientWidth
end sub

sub selectStart()
	if tvSiteTermList.readyState = "complete" and not isEmpty(sSelected) then tvSiteTermList.selectNode(sSelected)
end sub

sub onSiteTermSelect()
	set xmlSelected = window.event.xmlItem
	btnOK.disabled = CBool(isNull(xmlSelected))
end sub

sub onSiteTermExecute()
	onSiteTermSelect()
	onBtnOK()
end sub
</SCRIPT>

</HEAD>
<BODY STYLE='margin:0px;padding:10px'
	LANGUAGE='VBScript' onload='initSiteTermList()'>

<div ID='sitetermslist'></div>

<DIV STYLE='padding-bottom:4px'>
	<LABEL FOR='tvSiteTermList'>Choose a site-term from the list:</LABEL>
</DIV>

<DIV CLASS='clsQueryBldr' STYLE='PADDING: 0'>
	<DIV ID='elHeader' STYLE='WIDTH: 100%; MARGIN: 0; PADDING: 0; WIDTH: 150px; BORDER: thin outset #cccccc'>Site-Term Tokens</DIV>
	<DIV ID='tvSiteTermList' DATAXML='tvlist'
		STYLE='WIDTH: 100%; HEIGHT: 120px; BACKGROUND: white'
		LANGUAGE='VBScript'
		ONITEMSELECT='onSiteTermSelect()'
		ONITEMEXECUTE='onSiteTermExecute()'
		ONRESIZE='onWndResize()'
		ONREADYSTATECHANGE='selectStart()'>
	</DIV>
</DIV>

<DIV ALIGN='right' STYLE='padding-top:10px'>
	<BUTTON ID='btnOK' DISABLED STYLE='width:60px'
		LANGUAGE='VBScript' onclick='onBtnOK()'>OK</BUTTON>
	<SPAN STYLE='width:2px; margin:0px; padding:0px'></SPAN>
	<BUTTON ID='btnCancel' STYLE='width:60px'
		LANGUAGE='VBScript' onclick='onBtnCancel()'>Cancel</BUTTON>
</DIV>

</BODY>
</HTML>
